package com.dofast.bt.mvp.presenter.my;

import com.dofast.bt.R;
import com.dofast.bt.adapter.CollectArticleListAdapter;
import com.dofast.bt.base.BaseMvpPresenter;
import com.dofast.bt.bean.ArticleBean;
import com.dofast.bt.bean.AttentionBean;
import com.dofast.bt.bean.GoodsBean;
import com.dofast.bt.mvp.model.IMainModel;
import com.dofast.bt.mvp.model.MainModel;
import com.dofast.bt.mvp.view.activity.my.CollectArticleListView;

import org.xutils.ex.DbException;

import java.util.ArrayList;
import java.util.List;

/**
 * username:Created by hsj on 2016/12/22 0022.
 * class：
 * 类描述：收藏的文章
 */

public class CollectArticleListPresenter extends BaseMvpPresenter<CollectArticleListView> implements ICollectArcticleListPresenter {

    private List<ArticleBean> mList = null;
    private CollectArticleListAdapter adapter = null;
    private IMainModel mainModel = null;
    private ArticleBean articleBean = null;


    public CollectArticleListPresenter() {
        mainModel = new MainModel();
    }

    @Override
    public void initData() {
        checkViewAttach();
        mList = new ArrayList<ArticleBean>();
        adapter = new CollectArticleListAdapter(mList);
        mvpView.initAdapter(adapter);
        getWordData();


    }

    /**
     * 收藏的文章
     */
    private void getWordData() {

        ArticleBean good = new ArticleBean();
        good.setName("铁观音优劣茗茶分辨技巧");
        good.setArticleUrl("http://jingyan.baidu.com/article/597a0643b56c5c312b5243f7.html");
        good.setImg_head_locle(R.mipmap.head_store1);
        mList.add(good);
        ArticleBean good1 = new ArticleBean();
        good1.setName("铁观音泡茶技巧");
        good1.setArticleUrl("http://jingyan.baidu.com/article/219f4bf7d5dc80de442d380d.html");
        good1.setImg_head_locle(R.mipmap.head_store2);
        mList.add(good1);
        ArticleBean good2 = new ArticleBean();
        good2.setName("铁观音品尝技巧");
        good2.setArticleUrl("http://jingyan.baidu.com/article/2d5afd69ea61d485a2e28edc.html");
        good2.setImg_head_locle(R.mipmap.head_store3);
        mList.add(good2);
        ArticleBean good3 = new ArticleBean();
        good3.setName("茶叶枕头的做法");
        good3.setArticleUrl("http://m.zx.wed114.cn/shenghuo/20160805151718.html");
        good3.setImg_head_locle(R.mipmap.head_store4);
        mList.add(good3);
        ArticleBean good4 = new ArticleBean();
        good4.setName("茶的别称与雅号你知道多少");
        good4.setArticleUrl("https://m.baidu.com/from=1015785t/bd_page_type=1/ssid=0/uid=0/pu=sz%40320_1001%2Cta%40iphone_2_6.0_3_537%2Cusm%400/baiduid=B108A5635FF74ED9B4CC91DB541292D8/w=0_10_/t=iphone/l=3/tc?ref=www_iphone&lid=8842244492464509291&order=3&fm=alop&tj=www_normal_3_0_10_title&vit=osres&m=8&srd=1&cltj=cloud_title&asres=1&nt=wnor&title=%E8%8C%B6%E7%9A%84%E5%88%AB%E7%A7%B0%E4%B8%8E%E9%9B%85%E5%8F%B7%E4%BD%A0%E7%9F%A5%E9%81%93%E5%A4%9A%E5%B0%91%3F&dict=30&w_qd=IlPT2AEptyoA_ykwru1p8A_6EFZUmIYbrTAWcf7&sec=17499&di=b1ca1f18a844bcb1&bdenc=1&tch=124.0.76.435.0.0&nsrc=IlPT2AEptyoA_yixCFOxXnANedT62v3IEQGG_ytQ_zSviUi7xPPkFhhdXHKhVmuTIjbyum7NfMpWdVfvOiJ8k1-ZbPQoxmhNkinwdsjtgxC2&eqid=7ab5f684868050001000000058574e3f&wd=&clk_info=%7B%22srcid%22%3A%221599%22%2C%22tplname%22%3A%22www_normal%22%2C%22t%22%3A1482116791924%2C%22xpath%22%3A%22div-a-h3-em%22%7D");
        good4.setImg_head_locle(R.mipmap.head_store5);
        mList.add(good4);
        ArticleBean good5 = new ArticleBean();
        good5.setName("茶农如何烘焙出优质的铁观音");
        good5.setArticleUrl("http://bbs.tianya.cn/m/post-490-26508-1.shtml");
        good5.setImg_head_locle(R.mipmap.head_store6);
        mList.add(good5);
        adapter.notifyDataSetChanged();
    }


    @Override
    public void itemClick(int position) {

        mvpView.gotoWeb(mList.get(position).getArticleUrl());


    }

    @Override
    public void delete(int positon) {
        mList.remove(positon);
        adapter.notifyDataSetChanged();
    }

}
